package com.yinhai.tool;

import java.io.UnsupportedEncodingException;

/**
 * purpose 提供常用方法的封装
 * @author hp
 *
 */
public class UsualTools {
	
	private UsualTools(){}
	
	private static final UsualTools instance=new UsualTools();
	public  static final boolean isLinux=System.getProperty("os.name").startsWith("Linux");
	
	public static UsualTools getInstance()
	{
		return instance;
	}
	
	public  String changeCode(String s)
	{
//		String str=null;
//		try {
//			str=new String(s.getBytes("iso-8859-1"),"utf-8");
//		} catch (UnsupportedEncodingException e) {
//			e.printStackTrace();
//			str=s;
//		}
//		
//		return str;
		
		if(s==null||s.length()<1)return s;
		  for(int i=0;i<s.length();i++)
		  {
		    int j=s.charAt(i);//返回S字符串第一个字符表示的数字
		    if(j>128&&j<256)
		    {
		      try {
				s=new String(s.getBytes("ISO-8859-1"),"UTF-8");
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		      break;
		    }
		  }
		  return s;
	}

}
